/**
 * Copyright 2025 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

:host {
    --spectrum-actionbar-height: var(--spectrum-action-bar-height);
    --spectrum-actionbar-corner-radius: var(--spectrum-corner-radius-100);
    --spectrum-actionbar-item-counter-font-size: var(--spectrum-font-size-100);
    --spectrum-actionbar-item-counter-line-height: var(--spectrum-line-height-100);
    --spectrum-actionbar-item-counter-color: var(--spectrum-neutral-content-color-default);
    --spectrum-actionbar-emphasized-background-color: var(--spectrum-informative-background-color-default);
    --spectrum-actionbar-emphasized-item-counter-color: var(--spectrum-white);
    --spectrum-actionbar-spacing-outer-edge: var(--spectrum-spacing-300);
    --spectrum-actionbar-spacing-close-button-top: var(--spectrum-spacing-100);
    --spectrum-actionbar-spacing-close-button-start: var(--spectrum-spacing-100);
    --spectrum-actionbar-spacing-close-button-end: var(--spectrum-spacing-75);
    --spectrum-actionbar-spacing-item-counter-top: var(--spectrum-action-bar-top-to-item-counter);
    --spectrum-actionbar-spacing-item-counter-end: var(--spectrum-spacing-400);
    --spectrum-actionbar-spacing-action-group-top: var(--spectrum-spacing-100);
    --spectrum-actionbar-spacing-action-group-end: var(--spectrum-spacing-100);
    --spectrum-actionbar-shadow-horizontal: var(--spectrum-drop-shadow-x);
    --spectrum-actionbar-shadow-vertical: var(--spectrum-drop-shadow-y);
    --spectrum-actionbar-shadow-blur: var(--spectrum-drop-shadow-blur);
    --spectrum-actionbar-shadow-color: var(--spectrum-drop-shadow-color);
}

:host:lang(ja),
:host:lang(ko),
:host:lang(zh) {
    --spectrum-actionbar-item-counter-line-height-cjk: var(--spectrum-cjk-line-height-100);
}

@media (forced-colors: active) {
    :host,
    :host([emphasized]) #popover {
        --highcontrast-actionbar-popover-border-color: CanvasText;
    }
}

:host {
    padding: 0 var(--mod-actionbar-spacing-outer-edge, var(--spectrum-actionbar-spacing-outer-edge));
    z-index: 1;
    box-sizing: border-box;
    pointer-events: none;
    block-size: 0;
    opacity: 0;
    inset-block-end: 0;
}

:host([open]) {
    block-size: calc(var(--mod-actionbar-spacing-outer-edge, var(--spectrum-actionbar-spacing-outer-edge)) + var(--mod-actionbar-height, var(--spectrum-actionbar-height)));
    opacity: 1;
}

#popover {
    block-size: var(--mod-actionbar-height, var(--spectrum-actionbar-height));
    box-sizing: border-box;
    inline-size: 100%;
    border-radius: var(--mod-actionbar-corner-radius, var(--spectrum-actionbar-corner-radius));
    border-color: var(--highcontrast-actionbar-popover-border-color, var(--mod-actionbar-popover-border-color, var(--spectrum-actionbar-popover-border-color)));
    background-color: var(--mod-actionbar-popover-background-color, var(--spectrum-actionbar-popover-background-color));
    filter: drop-shadow(var(--mod-actionbar-shadow-horizontal, var(--spectrum-actionbar-shadow-horizontal)) var(--mod-actionbar-shadow-vertical, var(--spectrum-actionbar-shadow-vertical)) var(--mod-actionbar-shadow-blur, var(--spectrum-actionbar-shadow-blur)) var(--mod-actionbar-shadow-color, var(--spectrum-actionbar-shadow-color)));
    pointer-events: auto;
    flex-direction: row;
    margin: auto;
    padding-block: 0;
    display: flex;
    position: relative;
}

.close-button {
    flex-shrink: 0;
    margin-block-start: var(--mod-actionbar-spacing-close-button-top, var(--spectrum-actionbar-spacing-close-button-top));
    margin-inline-start: var(--mod-actionbar-spacing-close-button-start, var(--spectrum-actionbar-spacing-close-button-start));
    margin-inline-end: var(--mod-actionbar-spacing-close-button-end, var(--spectrum-actionbar-spacing-close-button-end));
}

.field-label {
    font-size: var(--mod-actionbar-item-counter-font-size, var(--spectrum-actionbar-item-counter-font-size));
    color: var(--mod-actionbar-item-counter-color, var(--spectrum-actionbar-item-counter-color));
    line-height: var(--mod-actionbar-item-counter-line-height, var(--spectrum-actionbar-item-counter-line-height));
    margin-block-start: var(--mod-actionbar-spacing-item-counter-top, var(--spectrum-actionbar-spacing-item-counter-top));
    margin-inline-end: var(--mod-actionbar-spacing-item-counter-end, var(--spectrum-actionbar-spacing-item-counter-end));
    padding: 0;
}

.field-label:lang(ja),
.field-label:lang(ko),
.field-label:lang(zh) {
    line-height: var(--mod-actionbar-item-counter-line-height-cjk, var(--spectrum-actionbar-item-counter-line-height-cjk));
}

.action-group {
    margin-block-start: var(--mod-actionbar-spacing-action-group-top, var(--spectrum-actionbar-spacing-action-group-top));
    margin-inline-start: auto;
    margin-inline-end: var(--mod-actionbar-spacing-action-group-end, var(--spectrum-actionbar-spacing-action-group-end));
}

:host([emphasized]) #popover {
    filter: none;
    background-color: var(--mod-actionbar-emphasized-background-color, var(--spectrum-actionbar-emphasized-background-color));
    border-color: #0000;
}

:host([emphasized]) .field-label {
    color: var(--mod-actionbar-emphasized-item-counter-color, var(--spectrum-actionbar-emphasized-item-counter-color));
}

:host([variant="sticky"]) {
    position: sticky;
    inset-inline: 0;
}

:host([variant="fixed"]) {
    position: fixed;
}

:host([flexible]) #popover {
    inline-size: auto;
}
